# -*- coding: utf-8 -*-
class WarehousingEntry < ActiveRecord::Base
  has_many :warehousing_entry_details ,:dependent => :destroy  #级联删除子表
  has_many :warehousing_entry_hxes ,:dependent => :destroy  #级联删除子表
  #belongs_to :from_warehouse, :class_name => "Warehouse" , :foreign_key => :to_warehouse_id
  #belongs_to :to_warehouse, :class_name => "Warehouse" , :foreign_key => :to_warehouse_id
  belongs_to :warehouse
  belongs_to :employee
  belongs_to :order_type
  belongs_to :department
  belongs_to :company
  belongs_to :vendor
  #关联采购单
  belongs_to :purchase_order

  scope :findWarehousingEntries, ->(conditionsStr,conditionsHash,paramsHash) { includes( [:purchase_order,:warehousing_entry_details]).where([conditionsStr,conditionsHash]).offset(paramsHash[:offset]).limit(paramsHash[:limit]).order('warehousing_entries.updated_at DESC')}

  scope :countWarehousingEntries, ->(conditionsStr,conditionsHash) { includes( [:purchase_order,:warehousing_entry_details]).where([conditionsStr,conditionsHash]).count()}


end
